home *** CD-ROM | disk | FTP | other *** search
/ Aminet 41 / Aminet 41 (2001)(Schatztruhe)[!][Feb 2001].iso / Aminet / dev / c / libmpeg_src.lha / gray.c < prev    next >
Encoding:
C/C++ Source or Header  |  1995-09-25  |  2.2 KB  |  83 lines

  1. /*
  2.  * Copyright (c) 1992 The Regents of the University of California.
  3.  * All rights reserved.
  4.  * 
  5.  * Permission to use, copy, modify, and distribute this software and its
  6.  * documentation for any purpose, without fee, and without written agreement is
  7.  * hereby granted, provided that the above copyright notice and the following
  8.  * two paragraphs appear in all copies of this software.
  9.  * 
  10.  * IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR
  11.  * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT
  12.  * OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE UNIVERSITY OF
  13.  * CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  14.  * 
  15.  * THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES,
  16.  * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
  17.  * AND FITNESS FOR A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS
  18.  * ON AN "AS IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATION TO
  19.  * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
  20.  */
  21.  
  22. #include <config.h>
  23. #include "video.h"
  24. #include "proto.h"
  25. #include "dither.h"
  26.  
  27.  
  28. /*
  29.  *--------------------------------------------------------------
  30.  *
  31.  * GrayDitherImage --
  32.  *
  33.  *    Dithers image into 128 gray scales. Simply maps luminance
  34.  *      value into 1 of 128 gray scale colors (divide by two, essentially).
  35.  *
  36.  * Results:
  37.  *    None.
  38.  *
  39.  * Side effects:
  40.  *    None.
  41.  *
  42.  *--------------------------------------------------------------
  43.  */
  44.  
  45. void
  46. GrayDitherImage(lum, cr, cb, out, h, w)
  47.     unsigned char *lum;
  48.     unsigned char *cr;
  49.     unsigned char *cb;
  50.     unsigned char *out;
  51.     int w, h;
  52. {
  53.  
  54.   int i, max = w*h/16;
  55.  
  56.   for (i=0; i<max; i++) {
  57.     out[0] = pixel[lum[0]];
  58.     out[1] = pixel[lum[1]];
  59.     out[2] = pixel[lum[2]];
  60.     out[3] = pixel[lum[3]];
  61.     out[4] = pixel[lum[4]];
  62.     out[5] = pixel[lum[5]];
  63.     out[6] = pixel[lum[6]];
  64.     out[7] = pixel[lum[7]];
  65.     out[8] = pixel[lum[8]];
  66.     out[9] = pixel[lum[9]];
  67.     out[10] = pixel[lum[10]];
  68.     out[11] = pixel[lum[11]];
  69.     out[12] = pixel[lum[12]];
  70.     out[13] = pixel[lum[13]];
  71.     out[14] = pixel[lum[14]];
  72.     out[15] = pixel[lum[15]];
  73.     out += 16;
  74.     lum += 16;
  75.   }
  76. }
  77.  
  78.  
  79.  
  80.  
  81.  
  82.  
  83.